from common.base_model import BasicModelMixin, CompanyMixin, CreateMixin, UpdateMixin, DeleteMixin
from exts import db
from common import constant


class StorageFlow(BasicModelMixin, db.Model, CompanyMixin, CreateMixin, UpdateMixin, DeleteMixin):
    __tablename__ = 'storage_flow'

    id = db.Column(db.Integer, primary_key=True)

    warehouse_id = db.Column(db.Integer, db.ForeignKey("warehouse.id"))
    warehouse = db.relationship("Warehouse")
    sku_id = db.Column(db.Integer, db.ForeignKey('sku.id'))
    sku = db.relationship("Sku")
    unit_id = db.Column(db.Integer, db.ForeignKey('unit.id'))
    unit = db.relationship("Unit")

    before_num = db.Column(db.DECIMAL(20, constant.COMMON_DECIMAL), default=0)
    after_num = db.Column(db.DECIMAL(20, constant.COMMON_DECIMAL), default=0)

    order_type = db.Column(db.String(constant.MIDDLE_DB_STR_LEN), nullable=False, default=constant.OrderType.PURCHASE)
    order_id = db.Column(db.Integer)

